package org.jmsmith.utilities.io;

import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

public class ExtractorTest {

    @Test
    public void testExtractFile() throws IOException {
        // Create a temporary file for testing
        var tempFile = new File("tempFile");
        tempFile.createNewFile();

        // Write some data to the file
        var writer = new FileWriter(tempFile);
        writer.write("Test data");
        writer.close();

        // Create a FileInputStream and ZipInputStream for the file
        var fis = new FileInputStream(tempFile);
        var zipIn = new ZipInputStream(fis);

        // Create a temporary output file
        var tempOutput = new File("tempOutput");

        // Call the method to test
        Extractor.extractFile(zipIn, tempOutput.getPath());
        zipIn.close();


        // Check that the output file exists and is not empty
        assertTrue(tempOutput.exists());
        assertTrue(tempOutput.length() > 0);

        // Clean up the temporary files
        tempFile.delete();
        tempOutput.delete();
    }
}
